Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Propose additional debug logging #2243

Merged
merged 4 commits into from
Dec 11, 2023

Conversation

sfc-gh-asawicki
Copy link
Collaborator

Allow to set additional debug logs in snowflake_grant_privileges_to_role resource.

Output from TestAcc_GrantPrivilegesToRole_onAccount test with only this flag set (without TF_LOG set to DEBUG):


2023/12/08 12:58:22.497066 sf-tf-additional-debug [DEBUG] Entering create grant privileges to role
2023/12/08 12:58:22.497078 sf-tf-additional-debug [DEBUG] Creating new client from db
2023/12/08 12:58:22.497142 sf-tf-additional-debug [DEBUG] Building privileges list based on config
2023/12/08 12:58:22.497164 sf-tf-additional-debug [DEBUG] Configuring account role grant privileges options
2023/12/08 12:58:22.497167 sf-tf-additional-debug [DEBUG] Configuring account role grant privileges options: on account
2023/12/08 12:58:22.497169 sf-tf-additional-debug [DEBUG] Setting global privileges on privileges to grant
2023/12/08 12:58:22.497174 sf-tf-additional-debug [DEBUG] About to grant privileges to account role
2023/12/08 12:58:22.497196 sf-tf-additional-debug [DEBUG] Grant privileges to account role
2023/12/08 12:58:22.497212 sf-tf-additional-debug [DEBUG] Grant privileges to account role: opts &{grant:false privileges:0x14000ba7030 on:0x14001122e20 accountRole:{name:SHEATAONRD} WithGrantOption:0x14000a54c3b}
2023/12/08 12:58:22.736432 sf-tf-additional-debug [DEBUG] After granting privileges to account role: err = <nil>
2023/12/08 12:58:22.736724 sf-tf-additional-debug [DEBUG] Setting ID to SHEATAONRD|MONITOR USAGE|false|false|true|false|false|false|false|false||||false||false|
2023/12/08 12:58:22.736744 sf-tf-additional-debug [DEBUG] Entering read grant privileges to role
2023/12/08 12:58:22.736749 sf-tf-additional-debug [DEBUG] Creating new client from db
2023/12/08 12:58:22.736781 sf-tf-additional-debug [DEBUG] Preparing to read privileges: on account
2023/12/08 12:58:22.736789 sf-tf-additional-debug [DEBUG] About to show grants
2023/12/08 12:58:22.736797 sf-tf-additional-debug [DEBUG] Show grants
2023/12/08 12:58:22.736845 sf-tf-additional-debug [DEBUG] Show grants: opts &{show:false Future:<nil> grants:false On:0x14000678aa0 To:<nil> Of:<nil> In:<nil>}
2023/12/08 12:58:23.131856 sf-tf-additional-debug [DEBUG] Show grants: query finished err = <nil>
2023/12/08 12:58:23.131910 sf-tf-additional-debug [DEBUG] Show grants: converting rows
2023/12/08 12:58:23.132571 sf-tf-additional-debug [DEBUG] Show grants: rows converted
2023/12/08 12:58:23.132582 sf-tf-additional-debug [DEBUG] After showing grants: err = <nil>
2023/12/08 12:58:23.132768 sf-tf-additional-debug [DEBUG] Filtering grants to be set on account: count = 170
2023/12/08 12:58:23.132780 sf-tf-additional-debug [DEBUG] Setting privileges on account
2023/12/08 12:58:27.131280 sf-tf-additional-debug [DEBUG] Entering read grant privileges to role
2023/12/08 12:58:27.131309 sf-tf-additional-debug [DEBUG] Creating new client from db
2023/12/08 12:58:27.131331 sf-tf-additional-debug [DEBUG] Preparing to read privileges: on account
2023/12/08 12:58:27.131339 sf-tf-additional-debug [DEBUG] About to show grants
2023/12/08 12:58:27.131343 sf-tf-additional-debug [DEBUG] Show grants
2023/12/08 12:58:27.131372 sf-tf-additional-debug [DEBUG] Show grants: opts &{show:false Future:<nil> grants:false On:0x1400118ff60 To:<nil> Of:<nil> In:<nil>}
2023/12/08 12:58:27.620753 sf-tf-additional-debug [DEBUG] Show grants: query finished err = <nil>
2023/12/08 12:58:27.621253 sf-tf-additional-debug [DEBUG] Show grants: converting rows
2023/12/08 12:58:27.621367 sf-tf-additional-debug [DEBUG] Show grants: rows converted
2023/12/08 12:58:27.621373 sf-tf-additional-debug [DEBUG] After showing grants: err = <nil>
2023/12/08 12:58:27.621607 sf-tf-additional-debug [DEBUG] Filtering grants to be set on account: count = 170
2023/12/08 12:58:27.621622 sf-tf-additional-debug [DEBUG] Setting privileges on account
2023/12/08 12:58:31.508041 sf-tf-additional-debug [DEBUG] Entering read grant privileges to role
2023/12/08 12:58:31.508067 sf-tf-additional-debug [DEBUG] Creating new client from db
2023/12/08 12:58:31.508084 sf-tf-additional-debug [DEBUG] Preparing to read privileges: on account
2023/12/08 12:58:31.508091 sf-tf-additional-debug [DEBUG] About to show grants
2023/12/08 12:58:31.508095 sf-tf-additional-debug [DEBUG] Show grants
2023/12/08 12:58:31.508123 sf-tf-additional-debug [DEBUG] Show grants: opts &{show:false Future:<nil> grants:false On:0x14000a3f510 To:<nil> Of:<nil> In:<nil>}
2023/12/08 12:58:31.824958 sf-tf-additional-debug [DEBUG] Show grants: query finished err = <nil>
2023/12/08 12:58:31.825000 sf-tf-additional-debug [DEBUG] Show grants: converting rows
2023/12/08 12:58:31.825059 sf-tf-additional-debug [DEBUG] Show grants: rows converted
2023/12/08 12:58:31.825064 sf-tf-additional-debug [DEBUG] After showing grants: err = <nil>
2023/12/08 12:58:31.825239 sf-tf-additional-debug [DEBUG] Filtering grants to be set on account: count = 170
2023/12/08 12:58:31.825247 sf-tf-additional-debug [DEBUG] Setting privileges on account
2023/12/08 12:58:35.182310 sf-tf-additional-debug [DEBUG] Entering update grant privileges to role
2023/12/08 12:58:35.182320 sf-tf-additional-debug [DEBUG] Creating new client from db
2023/12/08 12:58:35.182351 sf-tf-additional-debug [DEBUG] Checking if privileges have changed
2023/12/08 12:58:35.182545 sf-tf-additional-debug [DEBUG] Privileges have changed
2023/12/08 12:58:35.182564 sf-tf-additional-debug [DEBUG] Adding new privileges
2023/12/08 12:58:35.182567 sf-tf-additional-debug [DEBUG] Configuring account role grant privileges options
2023/12/08 12:58:35.182572 sf-tf-additional-debug [DEBUG] Configuring account role grant privileges options: on account
2023/12/08 12:58:35.182574 sf-tf-additional-debug [DEBUG] Setting global privileges on privileges to grant
2023/12/08 12:58:35.182576 sf-tf-additional-debug [DEBUG] About to grant privileges to account role
2023/12/08 12:58:35.182578 sf-tf-additional-debug [DEBUG] Grant privileges to account role
2023/12/08 12:58:35.182592 sf-tf-additional-debug [DEBUG] Grant privileges to account role: opts &{grant:false privileges:0x14000735b90 on:0x140006bd260 accountRole:{name:SHEATAONRD} WithGrantOption:<nil>}
2023/12/08 12:58:35.515306 sf-tf-additional-debug [DEBUG] After granting privileges to account role: err = <nil>
2023/12/08 12:58:35.515340 sf-tf-additional-debug [DEBUG] Setting new values
2023/12/08 12:58:35.515363 sf-tf-additional-debug [DEBUG] Entering read grant privileges to role
2023/12/08 12:58:35.515368 sf-tf-additional-debug [DEBUG] Creating new client from db
2023/12/08 12:58:35.515386 sf-tf-additional-debug [DEBUG] Preparing to read privileges: on account
2023/12/08 12:58:35.515393 sf-tf-additional-debug [DEBUG] About to show grants
2023/12/08 12:58:35.515397 sf-tf-additional-debug [DEBUG] Show grants
2023/12/08 12:58:35.515419 sf-tf-additional-debug [DEBUG] Show grants: opts &{show:false Future:<nil> grants:false On:0x14000f32c80 To:<nil> Of:<nil> In:<nil>}
2023/12/08 12:58:35.948865 sf-tf-additional-debug [DEBUG] Show grants: query finished err = <nil>
2023/12/08 12:58:35.948900 sf-tf-additional-debug [DEBUG] Show grants: converting rows
2023/12/08 12:58:35.949012 sf-tf-additional-debug [DEBUG] Show grants: rows converted
2023/12/08 12:58:35.949016 sf-tf-additional-debug [DEBUG] After showing grants: err = <nil>
2023/12/08 12:58:35.949063 sf-tf-additional-debug [DEBUG] Filtering grants to be set on account: count = 171
2023/12/08 12:58:35.949072 sf-tf-additional-debug [DEBUG] Setting privileges on account
2023/12/08 12:58:39.982971 sf-tf-additional-debug [DEBUG] Entering read grant privileges to role
2023/12/08 12:58:39.982996 sf-tf-additional-debug [DEBUG] Creating new client from db
2023/12/08 12:58:39.983013 sf-tf-additional-debug [DEBUG] Preparing to read privileges: on account
2023/12/08 12:58:39.983018 sf-tf-additional-debug [DEBUG] About to show grants
2023/12/08 12:58:39.983022 sf-tf-additional-debug [DEBUG] Show grants
2023/12/08 12:58:39.983047 sf-tf-additional-debug [DEBUG] Show grants: opts &{show:false Future:<nil> grants:false On:0x140009e0490 To:<nil> Of:<nil> In:<nil>}
2023/12/08 12:58:40.296690 sf-tf-additional-debug [DEBUG] Show grants: query finished err = <nil>
2023/12/08 12:58:40.296702 sf-tf-additional-debug [DEBUG] Show grants: converting rows
2023/12/08 12:58:40.296732 sf-tf-additional-debug [DEBUG] Show grants: rows converted
2023/12/08 12:58:40.296743 sf-tf-additional-debug [DEBUG] After showing grants: err = <nil>
2023/12/08 12:58:40.296790 sf-tf-additional-debug [DEBUG] Filtering grants to be set on account: count = 171
2023/12/08 12:58:40.296793 sf-tf-additional-debug [DEBUG] Setting privileges on account
2023/12/08 12:58:43.651627 sf-tf-additional-debug [DEBUG] Entering read grant privileges to role
2023/12/08 12:58:43.651661 sf-tf-additional-debug [DEBUG] Creating new client from db
2023/12/08 12:58:43.651686 sf-tf-additional-debug [DEBUG] Preparing to read privileges: on account
2023/12/08 12:58:43.651694 sf-tf-additional-debug [DEBUG] About to show grants
2023/12/08 12:58:43.651697 sf-tf-additional-debug [DEBUG] Show grants
2023/12/08 12:58:43.651721 sf-tf-additional-debug [DEBUG] Show grants: opts &{show:false Future:<nil> grants:false On:0x140011d7fb0 To:<nil> Of:<nil> In:<nil>}
2023/12/08 12:58:43.973002 sf-tf-additional-debug [DEBUG] Show grants: query finished err = <nil>
2023/12/08 12:58:43.973070 sf-tf-additional-debug [DEBUG] Show grants: converting rows
2023/12/08 12:58:43.973166 sf-tf-additional-debug [DEBUG] Show grants: rows converted
2023/12/08 12:58:43.973170 sf-tf-additional-debug [DEBUG] After showing grants: err = <nil>
2023/12/08 12:58:43.974048 sf-tf-additional-debug [DEBUG] Filtering grants to be set on account: count = 171
2023/12/08 12:58:43.974062 sf-tf-additional-debug [DEBUG] Setting privileges on account
2023/12/08 12:58:47.612229 sf-tf-additional-debug [DEBUG] Entering delete grant privileges to role
2023/12/08 12:58:47.612241 sf-tf-additional-debug [DEBUG] Creating new client from db
2023/12/08 12:58:47.613482 sf-tf-additional-debug [DEBUG] Configuring account role grant privileges options
2023/12/08 12:58:47.613493 sf-tf-additional-debug [DEBUG] Configuring account role grant privileges options: on account
2023/12/08 12:58:47.613496 sf-tf-additional-debug [DEBUG] Setting global privileges on privileges to grant
2023/12/08 12:58:47.613499 sf-tf-additional-debug [DEBUG] About to revoke privileges from account role
2023/12/08 12:58:47.613503 sf-tf-additional-debug [DEBUG] Revoke privileges from account role
2023/12/08 12:58:47.613578 sf-tf-additional-debug [DEBUG] Revoke privileges from account role: opts &{revoke:false GrantOptionFor:<nil> privileges:0x14000f3e460 on:0x140013f5360 accountRole:{name:SHEATAONRD} Restrict:<nil> Cascade:<nil>}
2023/12/08 12:58:47.907472 sf-tf-additional-debug [DEBUG] After revoking privileges from account role: err = <nil>
2023/12/08 12:58:47.907489 sf-tf-additional-debug [DEBUG] Cleaning resource id

Copy link

github-actions bot commented Dec 8, 2023

Integration tests success for 17a15a60c5c6ad46abce622fb96a49d503894094

sfc-gh-jcieslak
sfc-gh-jcieslak previously approved these changes Dec 8, 2023
sfc-gh-jcieslak
sfc-gh-jcieslak previously approved these changes Dec 8, 2023
Copy link

github-actions bot commented Dec 8, 2023

Integration tests success for 1c86941a8a4517a6b82b02da1dfdef703c886065

@@ -442,12 +443,15 @@ func (v GrantPrivilegesToAccountRoleID) String() string {
}

func CreateGrantPrivilegesToRole(d *schema.ResourceData, meta interface{}) error {
logging.DebugLogger.Printf("[DEBUG] Entering create grant privileges to role")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since you already have a debug logger, is it necessary to prefix each line with [DEBUG]?

# Conflicts:
#	pkg/resources/schema_acceptance_test.go
@sfc-gh-asawicki sfc-gh-asawicki marked this pull request as ready for review December 11, 2023 08:57
Copy link

Integration tests failure for b873d463dc48f2a9bd861b7873198e285d422044

@sfc-gh-jcieslak sfc-gh-jcieslak merged commit a0984cd into main Dec 11, 2023
7 of 8 checks passed
@sfc-gh-jcieslak sfc-gh-jcieslak deleted the add-debug-logging-to-grants-resource branch December 11, 2023 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants